import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Set;

public class ReadFile {
    public static void main(String[] args) {
        HashMap<String,Integer> m=new HashMap<>();
        try {
            BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\PC\\Desktop\\java-studying\\hello\\src\\text.txt"));
            String ss = null;
            while ((ss = reader.readLine()) != null) {
                String[] str = ss.split(" ");
                for (int i = 0; i < str.length; i++) {
                    String word = str[i];
                    if (m.containsKey(word)) {
                        m.put(word, m.get(word) + 1);
                    } else {
                        m.put(word, 1);
                    }
                }
            }
            Set<String> st = m.keySet();
            for (String k : st) {
                if (k.hashCode() != 0) {
                    char[] str = k.toCharArray();
                    for (int i = 0; i < str.length; i++) {
                        if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) {
                            System.out.print(str[i]);
                        }
                    }
                    System.out.println("出现了" + m.get(k.trim()) + "次");
                }
            }
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
}
